// https://leetcode.cn/problems/minimum-size-subarray-sum/description/

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& a) {
        int j = 0, sum = 0, mn = 1e9;
        for (int i = 0; i < a.size(); i++) {
            sum += a[i];
            while (sum >= target) {
                mn = min(mn, i - j + 1);
                sum -= a[j];
                j++;
            }    
        }
        return (mn == 1e9) ? 0 : mn;
    } 
};